package cart.api;

import cart.model.payment.PayLog;
import cart.model.payment.Payment;
import cart.model.payment.PaymentConfig;

/**
 * Created by Liang Wenxu on 2016/11/21.
 */
public interface PaymentApi {

    public Payment findPaymentById(String id);

    public PaymentConfig findPayConfigByCode(String code);

    public PaymentConfig findPayConfigById(String id);

    public Payment saveOrUpdate(Payment payment);

    public PayLog savePayLog(PayLog payLog);

    public String toString();

    public PayLog findPayLogById(Integer id);

    /**
     * 建立payment和paylog的关联
     *
     * @param paymentId
     * @param payLogId
     * @return
     */
    public int updatePaymentPayLogId(String paymentId,Integer payLogId);

    /**
     * 判断payLog是否已经支付过了，防止重复支付
     *
     * @param payLogId
     * @return
     */
    public String getPayStatus(Integer payLogId);

    /**
     * 支付成功后，修改payLog的状态
     *
     * @param payLogId
     */
    public int updatePayLogStatus(Integer payLogId,String status);

    /**
     * 支付成功后，修改payment的状态
     *
     * @param paymentId
     * @return
     */
    public int updatePaymentStatus(String paymentId,String status);
}
